#ifndef _NETKIT_SERVER_H
#define _NETKIT_SERVER_H

#include "connection_manager.h"
#include "tcp_socket.h"
#include "connection.h"
#include "processor.h"
#include "svr_config.h"
#include "fd_epoll.h"
#include "thread_pool.h"
#include "work_thread.h"
#include "task_runnable.h"

using namespace CThread;

namespace NetKit
{

class Server 
{
public:
	Server(Processor* pProessor);
	~Server();
	int Init(const char* pszConfFile);
	void Run();
		
private:
	void RecvConnection();
	void RecvConnection(int socket_pair_fd, Connection* pConn);
	bool IsOverloaded();

	void IgnoreSignal();
	int InitDaemon();	
private:
	SvrConfig m_SvrConf;
	ConnectionManager* m_pConnsManager;
	TcpSocket* m_pAcceptor;
	Processor* m_pProcessor;
	Epoll* m_pEpoll;
	ThreadPool* m_pThreadPool;
	WorkThreadFactory* m_pThreadFactory;
};


}
#endif //_NETKIT_SERVER_H

